<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>NexMagic Scholar</title>
    <link href="../css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="../css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="../css/animate.css" rel="stylesheet">
    <link href="../css/style.css?v=4.1.0" rel="stylesheet">
    <link href="../css/scholar/scholar.css" rel="stylesheet">
    <link rel="stylesheet" href="../css/dataGalaxy/index.css"/>
    <link rel="stylesheet" href="../css/dataGalaxy/dg-scholar.css"/>
    <style>
        body {
            overflow: auto;
            background-color: #eef3fa;
            height: 100%;
        }

        body.body-loading {
            overflow: hidden;
        }

    </style>
</head>
<body class="body-loading">
<div class="content">
    <div class="row header">
        <div class="container" style="position: relative;">
            <div style="padding: 0;width:250px;position: absolute;z-index: 1000">
                <!--<div class="header-logo">N-Scholar</div>-->
                <img src="../img/scholar/logo2.png" style="height:25px;margin-top:15px;"/>
            </div>
            <div style="text-align: right;">

                <div class="i-icon" style="text-align: right;display: inline-block;vertical-align: top;float: right;">
                    <span onclick="logout()" id="logout"><i class="fa fa-power-off"></i></span>
                    <span class="user-circle"><i class="fa fa-user" aria-hidden="true"></i></span>
                    <span style="margin-left:0" id="username"></span>
                </div>

                <div class="header-search"
                     style="width: 350px;display: inline-block;position: relative;vertical-align: top;float: right;">
                    <input type="text" class="form-control search-input" id="keyword" placeholder="TEXT HERE"/>
                    <button type="button" class="btn-control search-icon" onclick="queryExpertsMyself()"
                            style="right: -12px;"><i class="fa fa-search"></i></button>
                    <div id="auto_div"></div>
                </div>
            </div>
        </div>
    </div>
    <div class="container" id="box" v-cloak>
        <div class="row">
            <div class="col-md-12">
                <div id="treeMap" style="height:250px;" class="my-tree-map"></div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="contact-box" id="numProportion">
                    <div class="loading-box"></div>
                    <ul class="query-condition">
                        <li>
                            <div class="switch-li">
                                <span>N-index:</span>
                                <div class="switch-box">
                                    <span :class="qo.max == 10 ? 'label-mark' : ''" class="label"
                                          @click="addRange(-1, 10)"><10({{nIndexClassifyNum[0]}})</span>
                                    <span :class="qo.max == 50 ? 'label-mark' : ''" class="label"
                                          @click="addRange(10, 50)">10-50({{nIndexClassifyNum[1]}})</span>
                                    <span :class="qo.max == 80 ? 'label-mark' : ''" class="label"
                                          @click="addRange(50, 80)">50-80({{nIndexClassifyNum[2]}})</span>
                                    <!--class: label-mark 被选中-->
                                    <span :class="qo.min == 80 ? 'label-mark' : ''" class="label"
                                          @click="addRange(80, 101)">≥80({{nIndexClassifyNum[3]}})</span>
                                </div>
                            </div>
                        </li>
                        <li id="languageLi" class="switch-hide">
                            <div class="switch-li" style="padding-right: 23px;">
                                <span>Language:</span>
                                <div class="switch-box">
                                    <template v-for="(item, index) in languages">
                                        <span class="label" :class="qo.language == item.language ? 'label-mark' : ''"
                                              @click="addLanguage(item.language)">{{item.language}}({{item.num}})</span>
                                    </template>
                                </div>
                                <div class="languageIcon" @click="showAllLanguage()" style="display: none"><i
                                        :class="showLanguageFlag?'fa fa-chevron-up':'fa fa-chevron-down'"></i></div>
                            </div>
                        </li>
                        <li id="countryLi" class="switch-hide">
                            <div class="switch-li" style="padding-right: 23px;">
                                <span>Country:</span>
                                <div class="switch-box">
                                    <template v-for="(item,index) in countries">
                                    <span class="label" :class="qo.country == item.country ? 'label-mark' : ''"
                                          @click="addCountry(item.country)">{{item.country}}({{item.num}})</span>
                                    </template>
                                </div>
                                <div class="countryIcon" @click="showAllCountry()" style="display: none"><i
                                        :class="showCountryFlag?'fa fa-chevron-up':'fa fa-chevron-down'"></i></div>
                            </div>
                        </li>
                        <li>
                            <div class="switch-li">
                                <span>Paper Count:</span>
                                <div class="switch-box">
                                    <span :class="'label ' + (qo.papers5yOr10y == 5 ? 'label-mark' : '')"
                                          @click="queryExpertByPaperCount(5)">Last 5 years({{paperCountDistribution.papers5y}})</span>
                                    <span :class="'label ' + (qo.papers5yOr10y == 10 ? 'label-mark' : '')"
                                          @click="queryExpertByPaperCount(10)">Last 10 years({{paperCountDistribution.papers10y}})</span>
                                    <span :class="'label ' + (qo.papers5yOr10y == 0 ? 'label-mark' : '')"
                                          @click="queryExpertByPaperCount(0)">All Time({{paperCountDistribution.allTime}})</span>
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <p class="result-tips"><i>{{totalElements}}</i> relevant results found, <i>{{orgNum}}</i> institutions</p>
        <div class="row content-main">
            <div class="col-md-8" style="padding-right: 0;">
                <div class="result-list">
                    <div class="sort-row">
                        <div class="show-hide" @click="transShowAll()"><i
                                :class="showAll?'fa fa-chevron-up':'fa fa-chevron-down'"></i></div>
                        <div class="btn-group" :class="showAll?'':'oneLine'">
                            <button :class="qo.orderField == '`paperCount`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('paperCount')">
                                Relevance <i :class="'fa fa-sort-amount-' + qo.orderType"
                                             v-if="qo.orderField == '`paperCount`'"></i>
                            </button>

                            <button :class="qo.orderField == '`nIndex`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('nIndex')">
                                N-index <i :class="'fa fa-sort-amount-' + qo.orderType"
                                           v-if="qo.orderField == '`nIndex`'"></i>
                            </button>

                            <button :class="qo.orderField == '`AIndex`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('AIndex')">
                                A-index <i :class="'fa fa-sort-amount-' + qo.orderType"
                                           v-if="qo.orderField == '`AIndex`'"></i>
                            </button>
                            <button :class="qo.orderField == '`iIndex`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('iIndex')">
                                I-index<i :class="'fa fa-sort-amount-' + qo.orderType"
                                          v-if="qo.orderField == '`iIndex`'"></i>
                            </button>
                            <button :class="qo.orderField == '`pIndex`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('pIndex')">
                                P-index<i :class="'fa fa-sort-amount-' + qo.orderType"
                                          v-if="qo.orderField == '`pIndex`'"></i>
                            </button>
                            <button :class="qo.orderField == '`h-index`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('h-index')">
                                h-index <i :class="'fa fa-sort-amount-' + qo.orderType"
                                           v-if="qo.orderField == '`h-index`'"></i>
                            </button>
                            <button :class="qo.orderField == '`gIndex`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('gIndex')">
                                g-index <i :class="'fa fa-sort-amount-' + qo.orderType"
                                           v-if="qo.orderField == '`gIndex`'"></i>
                            </button>
                            <button :class="qo.orderField == '`pnum`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('pnum')">
                                #Paper <i :class="'fa fa-sort-amount-' + qo.orderType"
                                          v-if="qo.orderField == '`pnum`'"></i>
                            </button>
                            <button :class="qo.orderField == '`citations`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('citations')">
                                #Citation <i :class="'fa fa-sort-amount-' + qo.orderType"
                                             v-if="qo.orderField == '`citations`'"></i>
                            </button>
                            <button :class="qo.orderField == '`bnum`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('bnum')">
                                #Book <i :class="'fa fa-sort-amount-' + qo.orderType"
                                         v-if="qo.orderField == '`bnum`'"></i>
                            </button>
                            <button :class="qo.orderField == '`patentsNum`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('patentsNum')">
                                #Patent <i :class="'fa fa-sort-amount-' + qo.orderType"
                                           v-if="qo.orderField == '`patentsNum`'"></i>
                            </button>
                            <button :class="qo.orderField == '`patentsCit`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('patentsCit')" style="width:115px;">
                                #Patent-citation <i :class="'fa fa-sort-amount-' + qo.orderType"
                                                    v-if="qo.orderField == '`patentsCit`'"></i>
                            </button>
                            <button :class="qo.orderField == '`diversity`'?'btn sort-btn sort-active':'btn sort-btn '"
                                    type="button"
                                    @click="sortExpert('diversity')">
                                Diversity <i :class="'fa fa-sort-amount-' + qo.orderType"
                                             v-if="qo.orderField == '`diversity`'"></i>
                            </button>
                        </div>
                    </div>
                    <div class="person-info" v-for="(item,index) in experts">
                        <!--<div class="col-sm-2 person-info-mar">
                            <div class="text-center">
                                <img class="m-t-xs header-img" :onerror="defaultImg"
                                     :src="(item.img != undefined && item.img != '' && item.img != null)?(resourceUrl + item.img):'../img/scholar/head/common-head.png'">
                                &lt;!&ndash;<div class="m-t-xs font-bold">搜索相似</div>&ndash;&gt;
                            </div>
                        </div>-->
                        <div class="col-sm-12 person-info-mar">
                            <div class="list-main">
                                <h3 class="name" @click="gotoAnalysis(item)">
                                    <strong>{{qo.orderType=='asc'?(totalElements - nowPageNo*10 - index):(nowPageNo*10
                                        + index + 1)}}. {{item.name}}</strong>
                                </h3>
                                <div class="follow-btn">
                                    <i class="fa fa-eye"></i> {{item.viewCou}} views
                                </div>
                                <div class="condition">
                                    <p><i>N-index:</i> {{item.nIndex.toFixed(2)}}</p>
                                    <p><i>A-index:</i> {{item.aIndex.toFixed(2)}}</p>
                                    <p><i>I-index:</i> {{item.iIndex.toFixed(2)}}</p>
                                    <p><i>P-index:</i> {{item.pIndex.toFixed(2)}}</p>
                                    <p><i>h-index:</i> {{item.hIndex.toFixed(2)}}</p>
                                    <p><i>#Paper:</i> {{item.pnum}}</p>
                                    <!--<p><i>Citation:</i> {{item.citations}}</p>-->
                                </div>
                                <div class="person-detail">
                                    <p><i class="fa fa-map-marker"></i> {{item.country != undefined ? item.country :
                                        ''}}</p>
                                    <p class="orgArea">
                                        <i class="fa fa-home"></i>
                                        <template>{{item.authorsOrg}}</template>
                                    </p>
                                </div>
                                <p class="person-tips limitFosHeight" v-if="item.foSets != undefined">
                                    <!-- v-if="index < 5" -->
                                    <i class="fa fa-chevron-down" @click="showFos($event)"
                                       style="position: absolute; right: 15px;top:0; cursor: pointer"></i>
                                    <span v-for="(skill, index) in item.foSets">{{skill}}</span>
                                </p>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="search-loading" style="display: none">
                        <div class="sk-spinner sk-spinner-three-bounce">
                            <div class="sk-bounce1"></div>
                            <div class="sk-bounce2"></div>
                            <div class="sk-bounce3"></div>
                        </div>
                    </div>
                    <div class="my-page text-center">
                        <div class="btn-group">
                            <ul class="pagination" id="pagination1"></ul>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-4" style="padding-left: 13px;">
                <div class="graph-area">
                    <div class="ibox">
                        <div class="ibox-title">Research field graph</div>
                        <div class="full-view" onclick="showAllOfFields()">full view</div>
                        <div id="fieldsFamily" class="my-chat-map"></div>
                    </div>
                    <div class="ibox loading-mark">
                        <div class="ibox-title">Trend of related research</div>
                        <div style="position: relative">
                            <div id="relatedChart" class="my-chat-map"></div>
                            <div class="loading-box"></div><!-- loading模块 -->
                        </div>
                    </div>
                    <div class="ibox">
                        <div class="ibox-title">Research hotspots & locations</div>
                        <div class="full-view" onclick="showAllOfHotspots()">full view</div>
                        <div style="position: relative">
                            <div id="heatMap" class="my-chat-map"></div>
                            <div class="loading-box"></div>
                        </div>
                    </div>
                    <div class="ibox">
                        <div class="ibox-title">Graph network analysis</div>
                        <div class="full-view" onclick="showAllOfnetwork()">full view</div>
                        <div style="position: relative">
                            <div id="network" class="my-chat-map"></div>
                            <div class="loading-box"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="loading-box" style="z-index: 99999"></div>
<div style="display: none">
    <div class="loading">
        <div class="sk-spinner sk-spinner-three-bounce">
            <div class="sk-bounce1"></div>
            <div class="sk-bounce2"></div>
            <div class="sk-bounce3"></div>
        </div>
    </div>
</div>
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/layer/layer.js"></script>
<script src="../js/polyfill.min.js"></script>
<script src="../js/vue.min.js"></script>
<script src="../js/echarts/echarts.min.js"></script>
<script src="../js/echarts/world.js"></script>
<script src="../js/gAjax.js"></script>
<script src="../js/jqPaginator.js"></script>
<script src="../js/d3/d3.min.js"></script>
<script src="../js/dataGalaxy/dg-scholar.js"></script>

<!-- <script src="../js/fbd-ui.js"></script> -->

<script>
    window.onscroll = function () {
        if ($(window).scrollTop() > 0) {
            if (!$(".header").hasClass("s_down")) {
                $(".header").addClass("s_down");
            }
        } else {
            $(".header").removeClass("s_down");
        }
    }

    function logout() {
        setLoginToken(null);
        setStorage("scholar-user-name", null);
        window.location.href = "search1.html?showLogin=1";
    }

    function queryExpertsMyself(key) {
        var keyword = key ? key : $("#keyword").val().trim();
        var keywordArr = keyword.split(" ");
        keyword = "";
        for (var i in keywordArr) {
            keyword += keywordArr[i].substring(0, 1).toUpperCase() + keywordArr[i].substring(1) + (i == keywordArr.length ? '' : ' ');
        }

        keyword = keyword.trim();

        if (keyword != null && keyword.length > 0) {
            window.location.href = "searchList.html?keyword=" + keyword;
        } else {
            $("#keyword").val("")
            layer.msg('Please enter keywords!', {
                skin: 'message-box-fail',
                icon: 0,
                area: 'auto',
                maxWidth: '1000px',
                offset: '20px',
                anim: 0,
                time: 1000
            });
        }
    }

    $('#keyword').bind('keyup', function (event) {//回车执行查询
        if (event.keyCode == "13") {
            queryExpertsMyself();
        }
    });

    $(document).on("click", "text.children", function (event) {/*d3,父子领域树状图 text点击事件监听*/
        $("#keyword").val($(this).text());
        queryExpertsMyself();
        //event.stopPropagation(); // 阻止点击事件冒泡
    });

    var fosChart;

    var openFieldsName;

    function showAllOfFields() {/*展示更多父子领域关系*/
    	
        var keyword = kingVue.qo.name;
    	var fieldParentChild = kingVue.fieldParentChild;
        if (keyword == undefined || keyword == null) {
            layer.msg('数据加载中，请稍后重试！');
            return false;
        }
        
        var url = "fieldTree.html?keyword=" + openFieldsName;
        
        if(fieldParentChild == "parent") {
        	url = "fieldTree3.html?keyword=" + openFieldsName;
        }
        
        window.open(url);
    }

    var heatMapFlag = true;

    function showAllOfHotspots() {/*放大机构热力图*/
        var keyword = kingVue.qo.name;
        if (keyword == undefined || keyword == null) {
            layer.msg('数据加载中，请稍后重试！');
            return false;
        }
        window.open("locationsMap.html");
    }

    function showAllOfnetwork() {/*放大专家关系图*/
        var keyword = kingVue.qo.name;

        var min = kingVue.qo.min;
        var max = kingVue.qo.max;
        var language = kingVue.qo.language;
        var country = kingVue.qo.country;
        var papers5yOr10y = kingVue.qo.papers5yOr10y;
        if (!language) {
            language = ""
        }
        if (!country) {
            country = ""
        }

        if (keyword == undefined || keyword == null) {
            layer.msg('数据加载中，请稍后重试！');
            return false;
        }
        window.open("networkGraph.html?keyword=" + keyword + "&min=" + min
            + "&max=" + max
            + "&language=" + language
            + "&country=" + country
            + "&papers5yOr10y=" + papers5yOr10y
        );
    }

    var treeMapChart; // 树图聚类图
    var relatedChart; // 领域研究趋势图
    var heatMapChart; // 热力分布图
    var switchFlag = false; // 是否已查询国家和语言
    var kingVue = new Vue({
        el: '#box',
        data: {
            resourceUrl: "",
            showAll: false,
            experts: [],
            fosMap: {},
            qo: {
                orderType: "desc",
                orderField: "`h-index`",
                papers5yOr10y: 0,
                min: -1,
                max: 101
            },
            orgNum: 0,
            nIndexClassifyNum: [0, 0, 0, 0],
            totalElements: 0,
            nowPageNo: 0,
            languages: [],
            countries: [],
            moreFosInfo: [],
            paperCountDistribution: {papers5y: 0, papers10y: 0, allTime: 0},
            showLanguageFlag: false,
            showCountryFlag: false,
            defaultImg: 'this.src="../img/scholar/head/common-head.png"',
            hideLoading4ExpertAndTree: [false, false], // 专家和树图加载开关盒
            hideLoading4NICL: [false, false, false], // NIndex,Country, Language 加载开关盒
			fieldParentChild:"child"
        },
        created: function () {
            $("#username").html(getStorage("scholar-user-name").split("@")[0]);

            $(".loading-box").html($(".loading"));// 为所有box添加加载中动画
        },
        mounted: function () {
            var _this = this;
            var keyword = getUrlParam("keyword");
            var queryType = getUrlParam("queryType");
            /*是否从缓存中读取qo*/
            var cookieFlag = getUrlParam("cookieFlag");

            $("#keyword").val(keyword);

            _this.qo.name = keyword;

            if (queryType) {
                _this.qo.queryType = queryType;
            }

            /**
             * 确认领域
             */
            gAjax.request("expert/sureFosHasMaxExperts", {fosName: keyword}).then(function (result) {

                /**
                 * 当前查询的不是领域 比如 Lei Li
                 */
                if (result && !result.queryIsFos) {
                    _this.queryPaperByPos(result.fosName);
                    _this.queryFieldsFamily(result.fosName);
                    openFieldsName = result.fosName;
                } else {
                    _this.queryPaperByPos(keyword);
                    _this.queryFieldsFamily(keyword);
                    openFieldsName = keyword;
                }


                _this.scholarRelationship(keyword);
                _this.queryNIndexNumByKeyword(keyword);
            });

            /*
             * 初始查询第1页
             */

            _this.countOrgDistribution();

            _this.queryPaperCountDistribution();
            _this.queryExperts(1, true, cookieFlag);
            setStorage("scholar_searchKeyword", keyword);

            /*获取资源路径*/
            _this.resourceUrl = gAjax.resourceUrl;

            relatedChart = echarts.init(document.getElementById("relatedChart"));
            treeMapChart = echarts.init(document.getElementById("treeMap"));
            heatMapChart = echarts.init(document.getElementById("heatMap"));

            if ($("#countryLi .switch-li").height() > 34) {
                $(".countryIcon").show();
            }
        },
        watch: {
            totalElements: function (newVal) {
                if (!switchFlag) {
                    switchFlag = true;
                    var _this = this;
                    _this.queryLanguages(newVal);
                    _this.querycountries(newVal);
                }
            },
            languages: function () {
                this.$nextTick(function () { /*languages数据加载完，且页面渲染完执行*/
                    if ($("#languageLi .switch-li").height() > 34) {
                        $(".languageIcon").show();
                    }
                });
            },
            countries: function () {
                this.$nextTick(function () { /*countries数据加载完，且页面渲染完执行*/
                    if ($("#countryLi .switch-li").height() > 34) {
                        $(".countryIcon").show();
                    }
                });
            },
            hideLoading4ExpertAndTree: function (newVal) { // 根据各区域完成情况，隐藏loading遮罩
                if (newVal.indexOf(false) < 0) {
                    $("body").removeClass("body-loading");
                    $("body").children(".loading-box").hide();
                }
            },
            hideLoading4NICL: function (newVal) { // NIndex，国家和语言分布加载完成，取消laoding
                if (newVal.indexOf(false) < 0) {
                    $("#numProportion").children(".loading-box").hide();
                }
            }
        },
        methods: {
            queryPaperCountDistribution: function () { // 查5年10年内写过论文的专家人数分布
                var _this = this;
                gAjax.request("expert/get5Or10ExpertPapers", _this.qo).then(function (result) {
                    _this.paperCountDistribution.papers5y = result.papers5y;
                    _this.paperCountDistribution.papers10y = result.papers10y;
                    console.log(result);
                });
            },
            showFos: function (event) {
                var _dom = $(event.currentTarget);
                if (_dom.parent().attr("class").indexOf("limitFosHeight") > -1) {
                    _dom.parent().removeClass("limitFosHeight");
                    _dom.attr("class", "fa fa-chevron-up");
                } else {
                    _dom.parent().addClass("limitFosHeight");
                    _dom.attr("class", "fa fa-chevron-down");
                }
            },
            showAllLanguage: function () {
                var _this = this;
                if (_this.showLanguageFlag) {
                    $("#languageLi").addClass("switch-hide");
                } else {
                    $("#languageLi").removeClass("switch-hide");
                }
                _this.showLanguageFlag = !_this.showLanguageFlag;

            },
            showAllCountry: function () {
                var _this = this;
                if (_this.showCountryFlag) {
                    $("#countryLi").addClass("switch-hide");
                } else {
                    $("#countryLi").removeClass("switch-hide");
                }
                _this.showCountryFlag = !_this.showCountryFlag;
            },
            queryNIndexNumByKeyword: function (keyword) {//0-10,10-50,50-80,80-100各区域的数量
                var _this = this;
                gAjax.request("expert/getIndexNum", {name: keyword}).then(function (result) {
                    var arr = [];
                    result.forEach(function (item) {
                        arr.push(item["nIndexSum"]);
                    });
                    _this.nIndexClassifyNum = arr;
                    _this.$set(_this.hideLoading4NICL, 0, true);
                });

            },
            queryFieldsFamily: function (keyword) { /*查找父子领域*/
                var _this = this;
                /*集群图*/
                var width = 342,
                    height = 270;

                var cluster = d3.layout.cluster();
                var diagonal = d3.svg.diagonal()
                    .projection(function (d) {
                        return [d.y, d.x];
                    });

                var svg = d3.select("#fieldsFamily").append("svg")
                    .attr("width", width)
                    .attr("height", height)
                    .append("g");

                function calcX(total, num, index) {// 总长，总个数，当前个数
                    return total / (num + 1) * index;
                }

                gAjax.request("fosPac/query/list", {fName: keyword}).then(function (result) {
                    console.log(result);
                    _this.moreFosInfo = result;
                    var nodes = [];
                    var links = [];
                    var centerNode = {
                        name: keyword.length > 18 ? (keyword.substring(0, 18) + '...') : keyword,
                        value: keyword,
                        children: [],
                        depth: 1,
                        x: result.length > 0 ? 0 : 135,
                        y: 115
                    };
                    var cIndex = 0, pIndex = 0;
                    var parentFlag = false;
                    if (result[0] != undefined && result[0]["type"] == "parent") {
                        parentFlag = true;
                        centerNode.y = 210;
                    }
                    nodes.push(centerNode);
                    if (result.length > 0) {
                        for (var i in result) {
                            var item = result[i];
                            var nodeName = item["fName"];
                            var nodeType = item["type"];
                            /*if (cIndex > 11 && pIndex > 4) break;*/
                            if (cIndex > 11) break;
                            if (nodeType == "child") {
                                //console.log(item["f1.name"])
                                var target = {
                                    name: nodeName.length > 18 ? (nodeName.substring(0, 18) + '...') : nodeName,
                                    value: nodeName,
                                    depth: 2,
                                    x: -++cIndex,
                                    y: 195
                                };
                                links.push({source: 0, target: nodes.push(target) - 1});
                                
                                _this.fieldParentChild="child";
                                
                            } else if (nodeType == "parent" && pIndex++ < 5) {
                                var source = {
                                    name: nodeName.length > 18 ? (nodeName.substring(0, 18) + '...') : nodeName,
                                    value: nodeName,
                                    children: [],
                                    depth: 0,
                                    x: pIndex,
                                    y: 140,
                                    father: true
                                };
                                links.push({source: nodes.push(source) - 1, target: 0});
                                
                                _this.fieldParentChild="parent";
                                
                            }
                        }
                        //var flag_parents = false; // 是否有父领域
                        nodes.forEach(function (node) {
                            var num = node.x > 0 ? pIndex > 5 ? 5 : pIndex : node.x == 0 ? 1 : cIndex > 12 ? 12 : cIndex;
                            node.x = calcX(height, num, node.x == 0 ? 1 : Math.abs(node.x));
                            /*if (node.father !== undefined && node.father) {
                                flag_parents = true; // 有父领域
                            }*/
                        });
                        /*if (!flag_parents) {
                            nodes.forEach(function (node) {
                                if(node.children != undefined) {
                                    node.y = 120
                                } else {
                                    node.y = 200
                                }
                            });
                        }*/
                        links.forEach(function (link) {
                            link.source = nodes[link.source];
                            link.target = nodes[link.target];
                        });
                    }

                    var link = svg.selectAll(".link")
                        .data(links)
                        .enter()
                        .append("path")
                        .attr("style", "fill: none; stroke: #ccc; stroke-width: 1.5px;")
                        .attr("d", diagonal);

                    var node = svg.selectAll(".node")
                        .data(nodes)
                        .enter()
                        .append("a")
                        .attr("xlink:title", function (d) {
                            return d.value;
                        })
                        .attr("xlink:href", function (d) {
                            return "searchList.html?keyword=" + d.value;
                        })
                        .attr("class", "node")
                        .attr("transform", function (d) {
                            return "translate(" + d.y + "," + d.x + ")";
                        })

                    node.append("circle")
                        .attr("style", "fill: #fff; stroke: steelblue; stroke-width: 1.5px;")
                        .attr("r", 4.5);

                    node.append("text")
                        .attr("dx", function (d) {
                            if (d.depth == 1 && parentFlag) {
                                return 12 + d.name.length * 6;// 动态的text位置
                            } else {
                                return d.children ? -8 : 8;
                            }
                        })
                        
                        .attr("dy", 3)
                        .attr("class", function (d) {
                            return d.children ? "" : "children"
                        })
                        .style("text-anchor", function (d) {
                            return d.children ? "end" : "start";
                        })
                        .style("z-index", "99999")
                        .style("cursor", "pointer")
                        .text(function (d) {
                            return d.name;
                        });
                });
            },
            scholarRelationship: function (keyword) { /*专家关系图*/

                var _this = this;
                var reQo = _this.qo;
                reQo.nodeSize = 300;
                gAjax.request("expert/getRelateExpertParam", reQo).then(function (result) {

                    var svgs = $("#network").find("svg");
                    $.each(svgs, function (ine) {
                        $(this).remove();
                    });
                    var graph = {nodes: [], links: []};
                    var nodesSet = [];
                    var linksSet = [];

                    var nodesMap = {};
                    var linksMap = {};

                    var i = 0;
                    var j = 0;

                    result.forEach(function (item) {
                        /**
                         * 说明是有关系的
                         */

                        var expertId_ = item["eId"];
                        var index_ = $.inArray(expertId_, nodesSet);

                        if (index_ == -1) {
                            nodesSet.push(expertId_);
                            nodesMap[expertId_] = i++;
                            var sourceNode_ = {
                                id: nodesMap[expertId_],
                                name: item["ename"],
                                paper_count: item["epnum"],
                                url: "analysis.html?scholarId=" + item["eId"]
                            };

                            graph.nodes.push(sourceNode_);
                        }

                        if (item["relate"]) {

                            var expertId = item["rId"];
                            var index = $.inArray(expertId, nodesSet);

                            if (index == -1) {
                                nodesSet.push(expertId);
                                nodesMap[expertId] = i++;
                                var sourceNode = {
                                    id: nodesMap[expertId],
                                    name: item["rname"],
                                    paper_count: item["rpnum"],
                                    url: "analysis.html?scholarId=" + item["rId"]
                                };

                                graph.nodes.push(sourceNode);
                            }

                            var linkR1 = item["rId"] + "-" + item["eId"];
                            var linkR2 = item["eId"] + "-" + item["rId"];

                            var index1 = $.inArray(linkR1, linksSet);
                            var index2 = $.inArray(linkR2, linksSet);

                            /**
                             * 2个关系都不存在
                             */
                            if (index1 == -1 && index2 == -1) {
                                linksSet.push(linkR1);
                                linksSet.push(linkR2);
                                var link = {
                                    id: j++,
                                    source: nodesMap[item["eId"]],
                                    target: nodesMap[item["rId"]],
                                    co_count: Math.floor(Math.random() * 10 + 1)
                                };
                                graph.links.push(link);

                            }

                        }


                        /* if (!nodesMap[item["eId"]] && nodesMap[item["eId"]] != 0) {
                            nodesMap[item["eId"]] = i++;
                            var sourceNode = {
                                id: nodesMap[item["eId"]],
                                name: item["ename"],
                                paper_count: item["epnum"],
                                url: "analysis.html?scholarId=" + item["eId"]
                            };
                            graph.nodes.push(sourceNode);
                        } */

                        /* if (item["rId"] && !nodesMap[item["rId"]] && nodesMap[item["rId"]] != 0) {
                            nodesMap[item["rId"]] = i++;
                            var targetNode = {
                                id: nodesMap[item["rId"]],
                                name: item["rname"],
                                paper_count: item["rpnum"],
                                url: "analysis.html?scholarId=" + item["rId"]
                            };
                            graph.nodes.push(targetNode);
                        } */
                        // 过滤重复的关系，例如1-2，2-1
                        /* if (!linksMap[item["rId"] + "-" + item["eId"]] && !linksMap[item["eId"] + "-" + item["rId"]]) {
                            linksMap[item["eId"] + "-" + item["rId"]] = j + 1; // 从1开始，方便判断，如果从0开始，！0为true
                            var link = {
                                id: j++,
                                source: nodesMap[item["eId"]],
                                target: nodesMap[item["rId"]],
                                co_count: Math.floor(Math.random() * 10 + 1)
                            };
                            graph.links.push(link);
                        } */
                    });
                    initKG("../js/dataGalaxy/conf.json", "div #network", graph);
                    $("#network").next().hide();
                });
            },
            countOrgDistribution: function () { /*统计专家的领域全球热力分布*/
                var _this = this;
                gAjax.request("org/getOrgByKey", _this.qo).then(function (result) {
                    console.log(result);
                    var data = [];
                    result.forEach(function (item) {
                        var node = {
                            value: [item.longitude, item.latitude], name: item.name, id: item.id
                        };
                        data.push(node);

                        /* if (item.longitude && item.latitude) {
                            _this.orgNum++;
                        } */

                    })
                    var option = {
                        title: {
                            text: '',
                            left: 'center',
                            textStyle: {
                                color: '#000'
                            }
                        },
                        tooltip: {
                            trigger: 'item',
                            position: 'top',
                            formatter: function (params) {
                                var name = params.name;
                                if (name.length < 60) {
                                    return name;
                                }
                                var name_solved = "";
                                for (var i = 0; i < name.length; i += 60) {
                                    var endIndex = (i + 60) > name.length ? name.length : (i + 60);
                                    name_solved += name.slice(i, endIndex) + "<br/>";
                                }
                                return name_solved;
                            },
                        },
                        backgroundColor: '#fff',
                        visualMap: {
                            show: false,
                            min: 0,
                            max: 10,
                            /*splitNumber: 5,*/
                            calculable: true,
                            inRange: {
                                color: ['#50a3ba']/*, '#eac736', '#d94e5d']/*.reverse()*/
                            },
                            textStyle: {
                                color: '#000'
                            }
                        },
                        geo: {
                            map: 'world',
                            label: {
                                emphasis: {
                                    show: true
                                }
                            },
                            roam: true,
                            itemStyle: {
                                normal: {
                                    areaColor: '#eee',
                                    borderColor: '#a7bfe0'
                                },
                                emphasis: {
                                    areaColor: '#ffdf33'
                                }
                            }
                        },
                        series: [{
                            name: 'AQI',
                            type: 'scatter',
                            coordinateSystem: 'geo',
                            data: data,
                            symbolSize: 7,
                            label: {
                                normal: {
                                    show: false
                                },
                                emphasis: {
                                    show: false
                                }
                            },
                            itemStyle: {
                                emphasis: {
                                    borderColor: '#fff',
                                    borderWidth: 1
                                }
                            }
                        }]
                    };
                    heatMapChart.on('click', function (params) {
                        if (params.componentType == "geo") {
                            return;
                        } else {
                            window.open("orgScholar.html?orgId=" + params.data.id + "&fosName=" + _this.qo.name + "&orgName=" + params.name);
                        }
                    });
                    heatMapChart.setOption(option);
                    $("#heatMap").next().hide();
                });
            },
            queryPaperByPos: function (keyword) { /*按领域关键词统计论文数量*/
                var _this = this;
                gAjax.request("neo4j/paper/statisticsPaperByPos", {fos: keyword}).then(function (result) {
                    console.log(result);
                    var years = [];
                    var data = [];
                    if (result.length > 0) {
                        for (var i in result) {
                            years.push(result[i].pYear);
                            data.push(result[i].pac)
                        }
                    } else {
                        years.push(0);
                        data.push(0);
                    }

                    var option = {
                        xAxis: {
                            type: 'category',
                            data: years
                        },
                        yAxis: {
                            show: false,
                            type: 'value'
                        },
                        series: [{
                            data: data,
                            type: 'line',
                            color: '#69b4bd',
                        }]
                    };
                    relatedChart.setOption(option);
                    $("#relatedChart").next().hide();
                });
            },
            sortExpert: function (orderField) {
                var _this = this;
                if (_this.qo.orderField == "`" + orderField + "`") {
                    _this.qo.orderType = _this.qo.orderType == "asc" ? "desc" : "asc";
                } else {
                    _this.qo.orderType = "desc";
                    _this.qo.orderField = "`" + orderField + "`";
                }
                /*
                * 排序从第一页
                */
                _this.queryExperts(1);
            },
            gotoAnalysis: function (item) {
                setStorage("scholarId", item.id);
                var timestamp = new Date().getTime();
                
                /**
                * 发送被浏览的次数
                */
                gAjax.request("expert/addViewCou", {fId:item.fId}).then(function (result) {
                	window.location.href = "analysis.html?version=" + timestamp + "&fId=" + item.fId + "&nId=" + item.id;
                });
                
            },
            transShowAll: function () {
                this.showAll = !this.showAll;
            },
            addRange: function (min, max) { /*根据n-index区间筛选*/
                var _this = this;
                if (min == _this.qo.min && max == _this.qo.max) {
                    min = -1;
                    max = 101;
                }
                _this.qo.min = min;
                _this.qo.max = max;
                /**
                 * 添加方法
                 */

                _this.queryExperts(1);
                _this.countOrgDistribution();
                _this.scholarRelationship(_this.qo.name);
            },
            addLanguage: function (language) {
                var _this = this;
                _this.qo.language = language == _this.qo.language ? undefined : language;
                _this.queryExperts(1);

                _this.queryExperts(1);
                _this.countOrgDistribution();
                _this.scholarRelationship(_this.qo.name);

            },
            addCountry: function (country) {
                var _this = this;
                _this.qo.country = country == _this.qo.country ? undefined : country;
                _this.queryExperts(1);

                _this.queryExperts(1);
                _this.countOrgDistribution();
                _this.scholarRelationship(_this.qo.name);

            },
            queryExpertByPaperCount: function (index) { // 修改qo的papers5yOr10y重新查找
                var _this = this;
                _this.qo.papers5yOr10y = index ? index : 0;
                _this.queryExperts(1, true, false);

                _this.queryExperts(1);
                _this.countOrgDistribution();
                _this.scholarRelationship(_this.qo.name);

            },
            queryExperts: function (pageNo, chartFlag, cookieFlag) {/*params(页码，是否刷新treeMap，是否将qo存入浏览器缓存)*/
                $(".person-info").hide();
                $(".search-loading").show();
                var _this = this;
                var name_ = _this.qo.name;

                if (name_ == undefined || name_ == null || name_.length == 0) {
                    return;
                }

                if (name_ == "block chain") {
                    _this.qo.name = "blockchain";
                }

                _this.qo.pageNo = pageNo;

                if (cookieFlag) { /*从缓存读qo*/
                    _this.qo = JSON.parse(getStorage("scholar_searchList_qo"));
                } else { /*qo存入缓存*/
                    setStorage("scholar_searchList_qo", JSON.stringify(_this.qo));
                }

                //_this.countOrgDistribution(_this.qo);
                gAjax.request("expert/loadExperts", _this.qo).then(function (result) {
                    _this.totalElements = result.totalElements;
                    if (_this.paperCountDistribution.allTime == 0) {
                        _this.paperCountDistribution.allTime = result.totalElements;
                    }
                    _this.nowPageNo = result.number;
                    _this.experts = result.content;
                    if (result.number == 0) {
                        setStorage("expertList", result.content);
                    }
                    if (chartFlag) _this.refreshChart(_this.qo.name);
                    /*
                    * 分页传参 ：容器id，总页数，当前页码，回调函数
                    */
                    pageInit("#pagination1", result.totalPages, result.number, _this.queryExperts);
                    $(".search-loading").hide();
                    $(".person-info").show();
                    if (pageNo == 1) {
                        _this.$set(_this.hideLoading4ExpertAndTree, 0, true);
                    }

                });

                /**
                 * 查询领域数
                 */
                gAjax.request("expert/loadExpertsOrgCount", _this.qo).then(function (result) {
                    _this.orgNum = result;
                });

            },
            refreshChart: function (fos) { /*刷新图表*/
                var _this = this;
                var data = [
                    {name: 'fos1', children: [], svule: 0, value: 7},
                    {name: 'fos2', children: [], svule: 0, value: 8},
                    {name: 'fos3', children: [], svule: 0, value: 9},
                    {name: 'fos4', children: [], svule: 0, value: 10}
                ];
                gAjax.request("expert/expertUnwind2", {fos: fos}).then(function (result) {
                    /*准备数组*/
                    var flag = true;
                    console.log(result);
                    if (!result || result.length < 1) {/*显示专家自带的领域*/
                        _this.fosMap = {};
                        var content = _this.experts;
                        for (var i in content) {
                            if (content[i].foSets != undefined) {
                                /*累加map*/
                                for (var j in content[i].foSets) {
                                    if (j > 5) break;
                                    var fos = (content[i].foSets)[j];
                                    _this.fosMap[fos] = _this.fosMap[fos] == undefined ? 1 : (_this.fosMap[fos] + 1);
                                }
                            }
                        }
                        var i = 0;
                        for (var key in _this.fosMap) {
                            var colorMap = {0: "#6579ee", 1: "#9a9fff", 2: "#53bfc3", 3: "#9cd2c5"};
                            var index = 0;
                            if (i < Object.keys(_this.fosMap).length / 3.7) {
                                index = 0;
                            } else if (i < Object.keys(_this.fosMap).length / 1.9) {
                                index = 1;
                            } else if (i < Object.keys(_this.fosMap).length * 0.8) {
                                index = 2;
                            } else {
                                index = 3;
                            }
                            i++;
                            data[index].children.push({
                                name: key + "\n(" + _this.fosMap[key] + ")",
                                value: _this.fosMap[key],
                                link: 'searchList.html?queryType=JL&keyword=' + key,
                                itemStyle: {
                                    color: colorMap[index]
                                }
                            });
                        }
                    } else { /*显示聚类结果*/
                        flag = false;
                        /*var max = 0;*/
                        var fosMap = {};
                        var colorMap = {3: "#6579ee", 2: "#9a9fff", 1: "#53bfc3", 0: "#9cd2c5"};
                        var le = result.length / 4;

                        var index = 3;

                        result.forEach(function (item) {
                            var calc = item.fval;
                            //var index = calc < 0.25 ? 0 : (calc < 0.5 && calc >= 0.25) ? 1 : (calc < 0.75 && calc >= 0.5) ? 2 : 3;

                            if (data[index].children.length >= le) {
                                index--;
                            }

                            data[index].children.push({
                                name: item.fName + "\n(" + item.scholarNum + ")",
                                value: Math.pow(calc, 0.45), //
                                link: 'searchList.html?queryType=JL&keyword=' + item.fName,
                                itemStyle: {
                                    color: colorMap[index]
                                }
                            });

                            //data[index].svule += Math.pow(item.scholarNum, 0.45);
                        });

                        /**
                         * 聚类值计算
                         */
                        /*data.forEach(function (ite1) {
                        	var svl = ite1.svule;
                        	ite1.children.forEach(function (ite2) {
                        		ite2.value = (ite2.value/ite1.svule) * ite1.ivule;
                        	});
                        });*/
                    }

                    var option = {
                        tooltip: {
                            formatter: function (params) {
                                return params.name;
                            }
                        },
                        series: [{
                            type: 'treemap',
                            left: 0,
                            right: 0,
                            bottom: 0,
                            top: 0,
                            breadcrumb: {
                                show: 0
                            },
                            roam: false,
                            nodeClick: 'link',
                            data: data,
                            levels: [{}, {
                                itemStyle: {
                                    normal: {
                                        gapWidth: 1,
                                        borderColor: '#eee',
                                        borderWidth: 1
                                    }
                                }
                            }]
                        }]
                    };
                    treeMapChart.setOption(option);
                    _this.$set(_this.hideLoading4ExpertAndTree, 1, true);
                });

            },
            queryLanguages: function (expertsNum) {
                var _this = this;
                var _this = this;
                var name_ = _this.qo.name;

                if (name_ == undefined || name_ == null || name_.length == 0) {
                    return;
                }
                gAjax.request("expert/getLanguage", _this.qo).then(function (result) {
                    console.log(JSON.stringify(result));
                    result.forEach(function (item) {
                        expertsNum -= item["num"];
                    });
                    result.push({
                        language: "other",
                        num: expertsNum
                    });
                    _this.languages = result;
                    _this.$set(_this.hideLoading4NICL, 1, true);
                })
            },
            querycountries: function (expertsNum) {
                var _this = this;
                var _this = this;
                var name_ = _this.qo.name;

                if (name_ == undefined || name_ == null || name_.length == 0) {
                    return;
                }
                gAjax.request("expert/getCountry", _this.qo).then(function (result) {
                    result.forEach(function (item) {
                        expertsNum -= item["num"];
                    });
                    result.push({
                        country: "other",
                        num: expertsNum
                    });
                    _this.countries = result;
                    _this.$set(_this.hideLoading4NICL, 2, true);
                })
            }
        }
    });
</script>
</body>
</html>